<template>
  <div>
    <el-row justify="center" type="flex">
      <el-col :span="8">
        <el-form :model="ruleForm" status-icon ref="ruleForm" label-width="100px" class="demo-ruleForm">
          <el-form-item label="用户名" prop="username">
            <el-input type="username" v-model="ruleForm.username" autocomplete="off"></el-input>
          </el-form-item>
          <el-form-item label="密码" prop="password">
            <el-input type="password" v-model="ruleForm.password" autocomplete="off"></el-input>
          </el-form-item>
          <el-row justify="center" type="flex">
            <el-form-item>
              <el-button type="primary" @click="submitForm('ruleForm')">登录</el-button>
              <el-button @click="resetForm('ruleForm')">重置</el-button>
            </el-form-item>
          </el-row>
        </el-form>
      </el-col>
    </el-row>
  </div>
</template>

<script>
export default {
  name: "Login",
  data() {
    return {
      ruleForm: {
        password: '',
        username: ''
      }
    };
  },
  methods: {
    submitForm() {
      this.axios.post("http://localhost:8080/user/login", {
        username: this.ruleForm.username,
        password: this.ruleForm.password
      }).then(data => {
        console.log(data.data.code);
        if (data.data.code == "200") {
          location = "#/GoodsList";
        }
      })
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    }
  }
}
</script>

<style scoped>

</style>